<templateSet group="js_snippets">
  <template name="dr" value="document.addEventListener(&quot;DOMContentLoaded&quot;, function($TEXT$){});" description="вызвать callback после загрузки DOM" toReformat="true" toShortenFQNames="true">
    <variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="cl" value="console.log('$TEXT$');" description="записать в консоль лог" toReformat="false" toShortenFQNames="true">
    <variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="winrel" value="window.location.reload()" description="перезагрузить страницу" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="winloc" value="window.location = '$TEXT$'" description="переадресация (редирект)" toReformat="false" toShortenFQNames="true">
    <variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="geoloc" value="if(navigator.geolocation){&#10;    navigator.geolocation.getCurrentPosition(function(fsbkgb) { &#10;      var pod_kolpakom = true; &#10;    });&#10;}" description="геолокация" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="obj_iter" value="/**************************  iteration object ********************************/&#10;    let obj = document.querySelectorAll('$SELECTOR1$');&#10;    Object.keys(obj).forEach(function(index){&#10;&#10;        if(obj[index].parentNode.querySelector('$SELECTOR2$')){&#10;            obj[index]&#10;                .parentNode&#10;                .querySelector('$SELECTOR2$')&#10;                .textContent='$TEXT$'   }&#10;&#10;       &#10;    });&#10;/**************************  /end of iteration object ********************************/" description="пройтись по элементам объекта" toReformat="false" toShortenFQNames="true">
    <variable name="SELECTOR1" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="SELECTOR2" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="def_val" value="obj.var1 = p.timeout || 5000" description="присвоить по умолчанию" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="ajax_get" value="var xhttp = new XMLHttpRequest();&#10;xhttp.onreadystatechange = function() {&#10;    if (this.readyState == 4 &amp;&amp; this.status == 200) {&#10;       // Typical action to be performed when the document is ready:&#10;       document.getElementById(&quot;demo&quot;).innerHTML = xhttp.responseText;&#10;    }&#10;};&#10;xhttp.open(&quot;GET&quot;, &quot;filename&quot;, true);&#10;xhttp.send();" description="ajax запрос,  используем метод get" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="ajax_post" value="var xhttp = new XMLHttpRequest();&#10;xhttp.onreadystatechange = function() {&#10;    if (this.readyState == 4 &amp;&amp; this.status == 200) {&#10;       // Typical action to be performed when the document is ready:&#10;       document.getElementById(&quot;demo&quot;).innerHTML = xhttp.responseText;&#10;    }&#10;};&#10;xhttp.open(&quot;POST&quot;, &quot;ajax_test.php&quot;, true);&#10;xhttp.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);&#10;xhttp.send(&quot;fname=Severus&amp;lname=Snape&quot;);" description="ajax запрос, используем метод post" toReformat="true" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="dm_cntload" value="/** vanilla js ready - (only DOM !) **/&#10;document.addEventListener(&quot;DOMContentLoaded&quot;, function(){&#10;$TARGET$&#10;});&#10;/** end vanill js ready **/" description="DOMContentLoaded" toReformat="true" toShortenFQNames="true">
    <variable name="TARGET" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="cloneObjJSON" value="function jsonCopy(src) {&#10;    return JSON.parse(JSON.stringify(src));&#10;  }" description="clone object via json" toReformat="true" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="us" value="&quot;use strict&quot;;&#10;$END$" description="Inserts 'use strict' statement" toReformat="true" toShortenFQNames="true">
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="ritar" value="for ($VARKIND$ $INDEX$ = $ARRAY$.length - 1; $INDEX$ &gt;= 0; $INDEX$--) {&#10;  $VARKIND2$ $VAR$ = $ARRAY$[$INDEX$];&#10;  $END$&#10;}" description="Iterate elements of array in reverse order" toReformat="true" toShortenFQNames="true">
    <variable name="VARKIND" expression="jsSuggestDefaultVariableKind(false)" defaultValue="var" alwaysStopAt="false" />
    <variable name="INDEX" expression="jsSuggestIndexName()" defaultValue="&quot;i&quot;" alwaysStopAt="true" />
    <variable name="ARRAY" expression="jsArrayVariable()" defaultValue="&quot;array&quot;" alwaysStopAt="true" />
    <variable name="VARKIND2" expression="jsSuggestDefaultVariableKind()" defaultValue="var" alwaysStopAt="false" />
    <variable name="VAR" expression="jsSuggestVariableName()" defaultValue="&quot;o&quot;" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="ref" value="///&lt;reference path=&quot;$PATH$&quot;/&gt;&#10;$END$" description="Inserts reference path comment" toReformat="true" toShortenFQNames="false">
    <variable name="PATH" expression="complete()" defaultValue="&quot;&quot;" alwaysStopAt="true" />
    <context>
      <option name="TypeScript" value="true" />
    </context>
  </template>
  <template name="itin" value="for ($VARKIND$ $VAR$ in $ARRAY$) {&#10;  $END$&#10;}" description="Iterate (for..in)" toReformat="true" toShortenFQNames="true">
    <variable name="VARKIND" expression="jsSuggestDefaultVariableKind()" defaultValue="var" alwaysStopAt="false" />
    <variable name="ARRAY" expression="jsArrayVariable()" defaultValue="&quot;array &quot;" alwaysStopAt="true" />
    <variable name="VAR" expression="jsSuggestVariableName()" defaultValue="&quot;o&quot;" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="iter" value="for ($VARKIND$ $VAR$ of $ARRAY$) {&#10;  $END$&#10;}" description="Iterate (for..of) - ES2015" toReformat="true" toShortenFQNames="true">
    <variable name="VARKIND" expression="jsSuggestDefaultVariableKind()" defaultValue="var" alwaysStopAt="false" />
    <variable name="ARRAY" expression="jsArrayVariable()" defaultValue="&quot;array &quot;" alwaysStopAt="true" />
    <variable name="VAR" expression="jsSuggestVariableName()" defaultValue="&quot;o&quot;" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="itar" value="for ($VARKIND$ $INDEX$ = 0; $INDEX$ &lt; $ARRAY$.length; $INDEX$++) {&#10;  $VARKIND2$ $VAR$ = $ARRAY$[$INDEX$];&#10;  $END$&#10;}" description="Iterate elements of array" toReformat="true" toShortenFQNames="true">
    <variable name="VARKIND" expression="jsSuggestDefaultVariableKind(false)" defaultValue="var" alwaysStopAt="false" />
    <variable name="INDEX" expression="jsSuggestIndexName()" defaultValue="&quot;i&quot;" alwaysStopAt="true" />
    <variable name="ARRAY" expression="jsArrayVariable()" defaultValue="&quot;array&quot;" alwaysStopAt="true" />
    <variable name="VARKIND2" expression="jsSuggestDefaultVariableKind()" defaultValue="var" alwaysStopAt="false" />
    <variable name="VAR" expression="jsSuggestVariableName()" defaultValue="&quot;o&quot;" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="importns" value="import * as $ITEM$ from &quot;$MODULE$&quot;;&#10;$END$" description="Import statement - import * as b from 'a'" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <variable name="ITEM" expression="jsSuggestImportedEntityName()" defaultValue="Namespace" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="importitems" value="import {$ITEM$$END$} from &quot;$MODULE$&quot;;&#10;" description="Import statement - import {b} from 'a'" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <variable name="ITEM" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="importdefault" value="import $ITEM$ from &quot;$MODULE$&quot;;&#10;$END$" description="Import statement - import b from 'a'" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <variable name="ITEM" expression="jsSuggestImportedEntityName()" defaultValue="Namespace" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="fori" value="for($VARKIND$ $INDEX$ = 0; $INDEX$ &lt; $LIMIT$; $INDEX$++) {&#10;  $END$&#10;}" description="Create iteration loop" toReformat="true" toShortenFQNames="true">
    <variable name="VARKIND" expression="jsSuggestDefaultVariableKind(false)" defaultValue="var" alwaysStopAt="false" />
    <variable name="INDEX" expression="jsSuggestIndexName()" defaultValue="" alwaysStopAt="true" />
    <variable name="LIMIT" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="flow" value="// @flow" description="Inserts @flow annotation" toReformat="true" toShortenFQNames="true">
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="exportitems" value="export {$ITEM$$END$};&#10;" description="Export statement - export {b}" toReformat="true" toShortenFQNames="true">
    <variable name="ITEM" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="exportfrom" value="export {$ITEM$$END$} from &quot;$MODULE$&quot;;&#10;" description="Export statement - export {b} from 'a'" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <variable name="ITEM" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="exportall" value="export * from &quot;$MODULE$&quot;;&#10;$END$" description="Export statement - export * from 'a'" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE" expression="complete()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="defn" value="define([&quot;$MODULE_REF$&quot;], function($MODULE_VAR$) {&#10;$END$&#10;});" description="Inserts define() expression" toReformat="true" toShortenFQNames="true">
    <variable name="MODULE_REF" expression="complete()" defaultValue="&quot;&quot;" alwaysStopAt="true" />
    <variable name="MODULE_VAR" expression="jsDefineParameter(MODULE_REF)" defaultValue="mod" alwaysStopAt="true" />
    <context>
      <option name="JS_STATEMENT" value="true" />
    </context>
  </template>
  <template name="use_form_data" value="/********************************************************/&#10;var formElement = document.querySelector(&quot;form&quot;);&#10;var formData = new FormData(formElement);&#10;var request = new XMLHttpRequest();&#10;request.open(&quot;POST&quot;, &quot;submitform.php&quot;);&#10;formData.append(&quot;serialnumber&quot;, serialNumber++);&#10;request.send(formData);&#10;/********************************************************/" description="использование FormData" toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
  <template name="class_validator" value="/*------------------------------------------------------------------*/&#10;/**&#10;*addCheck - callback functions for checking value&#10;*/&#10;export default class {&#10;  checks = [];&#10;&#10;  addCheck(fn) {&#10;    this.checks.push(fn);&#10;  }&#10;&#10;  isValid(data) {&#10;    return this.checks.every((fn) =&gt; fn(data));&#10;  }&#10;}&#10;/*-------------------------------------------------------------------------*/" description="" toReformat="false" toShortenFQNames="true" />
  <template name="location" value="var currentURL = window.location.href;&#10;var currentHost = window.location.host;&#10;var currentHostname = window.location.hostname;&#10;var currentPort = window.location.port;&#10;var currentProtocol = window.location.protocol;&#10;var currentPathname = window.location.pathname;&#10;var currenthash = window.location.hash;&#10;var currentSearchString = window.location.search;" description="window.location ..." toReformat="false" toShortenFQNames="true">
    <context>
      <option name="JAVA_SCRIPT" value="true" />
    </context>
  </template>
</templateSet>